﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Unis.Framework.Core.Utility;

using KingRoad.EPM.CompletionMaterialsEntity.Model;
using KingRoad.EPM.CompletionMaterialsDAL.BcdFileListService;
using KingRoad.EPM.CompletionMaterialsDAL.BcdVolumeDirectoryService;


namespace KingRoad.EPM.CompletionMaterialsBLL.UIRules
{
    /// <summary> 
    /// 案卷目录表UIRule 
    /// </summary> 
    public class BcdFilelistUIRule
    {
        private readonly IBcdFilelistService _bcdFilelistService;
        private BcdVolumedirectoryUIRule _bcdVolumedirectoryUIRule;
        
        
        public BcdFilelistUIRule(){}
        
        /// <summary> 
        /// construct function... 
        /// </summary> 
        public BcdFilelistUIRule(IBcdFilelistService  bcdFilelistService)
        {
           _bcdFilelistService=bcdFilelistService;
        }

        /// <summary>
        /// 根据条件获取信息
        /// </summary>
        /// <returns></returns>
        public List<BcdFilelistInfo> GetEntityListBySql(string sql)
        {
            var ret = _bcdFilelistService.GetEntityList(sql);
            return ret;
        }
        /// <summary>
        /// 根据条件分页查询信息
        /// </summary>
        /// <param name="numCurrentPage">当前页</param>
        /// <param name="numPerPage">每页数据大小</param>
        /// <param name="orderByField">排序字段名称</param>
        /// <param name="totalRecord">总数据量</param>
        /// <param name="sqlCondition">sql查询条件</param>
        /// <param name="desc">排序方式</param>
        /// <param name="table">表名</param>
        /// <returns></returns>
        public List<BcdFilelistInfo> GetEntityListByContionRe(int numCurrentPage, int numPerPage,
                                                                        string orderByField, out int totalRecord, string sqlCondition, string desc,string table)
        {
            var list = _bcdFilelistService.GetEntityListByContionRe(numCurrentPage, numPerPage, orderByField, out totalRecord, sqlCondition,desc,table);
            return list;
        }
        /// <summary>
        /// 查看
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public BcdFilelistInfo GetEntityById(Guid id)
        {
            var ret = _bcdFilelistService.GetEntityById(id);
            return ret;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool InsertEntity(BcdFilelistInfo entity)
        {
            var ret = _bcdFilelistService.InsertEntity(entity);
            return ret > 0;
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool UpdateEntity(BcdFilelistInfo entity)
        {
            var ret = _bcdFilelistService.UpdateEntity(entity);
            return ret > 0;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool DeleteEntity(string id)
        {
            var ret = _bcdFilelistService.DeleteEntityByStringID(id);
            return ret > 0;
        }

         /// <summary>
        /// 根据条件获取最大档案流水号
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public int GetNumbBySql(string sql)
        {
            return _bcdFilelistService.GetNumbBySql(sql);
        }

        /// <summary>
        /// 根据项目id，文档类型id 获取该项目此文档类型下案卷个数
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public int GetCountBySql(string sql=" 1=1 ")
        {
            return _bcdFilelistService.GetCountBySql(sql);
        }

         /// <summary>
        /// 插入案卷前操作 将已有案卷及之后案卷流水号+1
        /// </summary>
        /// <param name="Where"></param>
        /// <returns></returns>
        public int InsertNumb(string sql)
        {
            return _bcdFilelistService.InsertNumb(sql);
        }
    }
}

